package com.fenxiangle.yueding.feature.mine.view;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.entity.bo.AliPayBo;
import com.fenxiangle.yueding.entity.bo.MyAccountBo;
import com.fenxiangle.yueding.feature.extension.contract.ExtensionContract;
import com.fenxiangle.yueding.feature.focus.view.WithdrawDepositActivity;
import com.fenxiangle.yueding.feature.publish.contract.PayContract;
import com.fenxiangle.yueding.feature.publish.dependencies.pay.DaggerPayComponent;
import com.fenxiangle.yueding.feature.publish.dependencies.pay.PayPresenterModule;
import com.suozhang.framework.framework.BaseActivity;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;

public class MyServiceActivity extends BaseActivity implements  PayContract.View  {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.btn_commission)
    TextView btnCommission;
    @Inject
    PayContract.Presenter presenter;
    @BindView(R.id.commission_moey)
    TextView commissionMoey;
    MyAccountBo extensionBo=null;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_extendc_commission;
    }

    @Override
    protected void initInjector() {
        DaggerPayComponent.builder().payPresenterModule(new PayPresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void onStart() {
        super.onStart();
        presenter.getMyAccount();
    }

    @Override
    protected void initData() {
        initToolBar(toolbar, "服务费", true, true);
    }



    @OnClick(R.id.btn_commission)
    public void onViewClicked(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.btn_commission:
                if(extensionBo==null){
                    return;
                }
                intent = new Intent(this, WithdrawDepositActivity.class);
                intent.putExtra("extensionBo",extensionBo.getServiceCharge()+"");
                intent.putExtra("commissionType",3);
                startActivity(intent);
                break;
        }
    }



    @Override
    public void showAliPayData(String aliPayData) {

    }

    @Override
    public void showWxPayData(AliPayBo.WechatBo wechatBo) {

    }

    @Override
    public void showError(String error) {

    }

    @Override
    public void showAccountSuccess(MyAccountBo s) {
        extensionBo=s;
        if (s != null) {
            commissionMoey.setText(s.getServiceCharge()+"元");
        }
    }
}
